package Servlet;

import com.cyy.bean.history;
import com.cyy.dao.historyDao;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/confirm")
public class confirmServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String userName=request.getSession().getAttribute("name").toString();
        String time=request.getParameter("time");
        historyDao historyDao = new historyDao();
        try {
            historyDao.updateState(userName,time);
        } catch (SQLException | ClassNotFoundException throwables) {
            throwables.printStackTrace();
        }
        request.getRequestDispatcher("/showHistory").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request,response);
    }
}
